package com.jdbc;

import java.sql.*;

// Notice, do not import com.mysql.cj.jdbc.*
// or you will have problems!

public class LoadDriver {


    public static void main(String[] args) {

        Statement stmt = null;
        ResultSet rs = null;
        Connection conn = null;



        try {
            conn = DriverManager.getConnection("jdbc:mysql://localhost/test?" +
                    "user=root&password=root");
            stmt = conn.createStatement();




//            if (stmt.execute("SELECT foo FROM bar")) {
//                rs = stmt.getResultSet();
//            }
            CallableStatement cStmt = conn.prepareCall("{call demoSp(?, ?)}");

            cStmt= conn.prepareCall("{call demoSp(?,?)}");
            cStmt.setString(1, "22");
            cStmt.setString(2, "33");
            cStmt.execute();

            System.out.println(cStmt.getString("inOutParam"));

        }
        catch (SQLException ex){
            // handle any errors
            System.out.println("SQLException: " + ex.getMessage());
            System.out.println("SQLState: " + ex.getSQLState());
            System.out.println("VendorError: " + ex.getErrorCode());
        }
        finally {
            // it is a good idea to release
            // resources in a finally{} block
            // in reverse-order of their creation
            // if they are no-longer needed

            if (rs != null) {
                try {
                    rs.close();
                } catch (SQLException sqlEx) { } // ignore

                rs = null;
            }

            if (stmt != null) {
                try {
                    stmt.close();

                } catch (SQLException sqlEx) { } // ignore

                stmt = null;
            }
        }






    }



}